package furthestDistanceFromOrigin;

public class Solution {
    public int furthestDistanceFromOrigin(String moves) {
        // 统计'L'和'R'和'_'的数量
        int lCount = 0,rCount = 0,_Count = 0;
        for (int i = 0; i < moves.length(); i++) {
            if(moves.charAt(i) == 'L')lCount++;
            else if (moves.charAt(i) == 'R')rCount++;
            else _Count++;
        }
        return Math.max(Math.abs(lCount-rCount+_Count),Math.abs(lCount-rCount-_Count));
    }
}
